﻿using Gadgeteer.Modules.DFRobot;
using Microsoft.SPOT;

using GT = Gadgeteer;

namespace TestApp
{
    public partial class Program
    {
        private Temperature _temp;
        private int _counter;

        void ProgramStarted()
        {
            Debug.Print("Program Started");

            _temp = new Temperature(3);

            _temp.LowPowerMode = true;
            _temp.Resolution = Temperature.ResolutionBits.R05;
            _temp.SensorAddress = Temperature.Address.A1001000;
            
            GT.Timer timer = new GT.Timer(2000);
            timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);

            timer.Start();
        }

        void timer_Tick(GT.Timer timer)
        {
            _counter++;

            switch (_counter)
            {
                case 30:
                    _temp.Resolution = Temperature.ResolutionBits.R025;
                    Debug.Print("R025");
                    break;
                case 60:
                    _temp.Resolution = Temperature.ResolutionBits.R0125;
                    Debug.Print("R0125");
                    break;
                case 90:
                    _temp.Resolution = Temperature.ResolutionBits.R00625;
                    Debug.Print("R00625");
                    break;
            }

            Debug.Print(_temp.GetTemperature().ToString());
        }
    }
}
